//
//  SettingColorViewController.swift
//  XingCeHelper
//
//  Created by 申铭 on 2022/12/8.
//

import UIKit
import Colorful

protocol SettingColorViewControllerDelegate: AnyObject {
    /// 颜色改变
    func colorChanged(_ color: UIColor)
}

class SettingColorViewController: BaseViewController {
    
    @IBOutlet weak var colorPicker: ColorPicker!
    
    weak var delegate: SettingColorViewControllerDelegate?
    
    override func viewDidLoad() {
        super.viewDidLoad()

        colorPicker.addTarget(self, action: #selector(self.handleColorChanged(picker:)), for: .valueChanged)
        colorPicker.set(color: UIColor(displayP3Red: 1.0, green: 1.0, blue: 0, alpha: 1), colorSpace: .sRGB)
    }
    
    @objc func handleColorChanged(picker: ColorPicker) {
        delegate?.colorChanged(picker.color)
    }

    @IBAction func clickCloseBtn(_ sender: Any) {
        dismiss(animated: true)
    }
}
